import { Get, Inject, Provide, Query } from '@midwayjs/decorator';
import {
  CoolController,
  BaseController,
} from '@cool-midway/core';
import { MangoCityService } from '../../../service/city';

/**
 * 图库
 */
@Provide()
@CoolController()
export class MangoAppOpenCityController extends BaseController {
  @Inject()
  mangoCityService: MangoCityService;
  /**
   * 获取全国所有城市
   */
  @Get('/all', { summary: '获取全国所有城市' })
  async getAll() {
    const res = await this.mangoCityService.getAll()
    return this.ok(res);
  }
  /**
   * 根据城市ID获取行政区/县
   */
  @Get('/region', { summary: '根据城市ID获取行政区/县' })
  async getRegionByCityId(@Query('city_id') city_id: number) {
    const res = await this.mangoCityService.getRegionByCityId(city_id)
    return this.ok(res);
  }
}
